<layout name="Public/layout"/>     
{:jumps($infos['authority'],CONTROLLER_NAME)}

        <!--主要区域开始-->
        <div id="main">            

            <form action="__SELF__" method="post" class="main_form">
                <input type="hidden" name='id' value='{$info.id}'/>
                <div class="text_info clearfix"><span>角色名称：</span></div>
                <div class="input_info">
                    <input type="text" class="width200" name='role_name' value='{$info.role_name}'/>
                    <span class="required">*</span>
                    <div class="validate_msg_medium">不能为空，且为20长度的字母、数字和汉字的组合</div>
                </div>                    
                <div class="text_info clearfix"><span>设置权限：</span></div>
                <div class="input_info_high">
                    <div class="input_info_scroll">
                        <ul>
<!--遍历权限-->
<volist name='res' id='vo'>
                        <li><input type="checkbox" value='{$vo.id}' name='privliege_id[]'
                            <php>
                                if( strstr( $info['names'],$vo['name'] ) ){
                                    echo 'checked';
                                }
                            </php>          
                                   />{$vo.name}</li>   
</volist>                                                        
                        </ul>
                    </div>
                    <span class="required">
<input type="button" value="增加" class="btn_add" onclick="location.href='{:U('Privilege/add')}';" />
                    </span>
                    <div class="validate_msg_tiny">至少选择一个权限</div>
                </div>
                <div class="button_info clearfix">
                    <input type="button" value="保存" class="btn_save" onclick="send()" />
                    <input type="button" value="取消" class="btn_save" />
                </div>
            </form>
        </div>
        <!--主要区域结束-->

<script type="text/javascript">
    $(function(){
        //点击之后的图标
        $('.role_off').addClass('role_on').removeClass('role_off');
    });  
</script>
<script type="text/javascript">
    function send(){

                $.ajax({
                    url: '__SELF__',
                    type: 'post',
                    dataType:'json',
                    data: $(".main_form").serializeArray(),
                    success: function(data) {
    //                    console.log(data);
                        //判断是否添加成功！
                        if(data.status==0){
                            layer.msg(data.info,{icon: 5});
                        }else{
                            layer.msg(data.info,{icon: 6});

                            //延迟跳转
                            setTimeout(function () {
                                location.href = "{:U('Role/index')}";
                            }, {:C('AJAX_TIME')});


                        }

                    }
                });
            
    }
</script>